JavaScript typeof v.s. instanceof
構文がそれぞれ違うし、返り値の型も微妙に違う
code:js
// typeof 値 -> "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
console.log(typeof "Hello"); // "string"
console.log(typeof null); // "object" (!)
console.log(typeof ((a, b) => a + b)); // "function"
console.log(typeof { a: 1, b: 2 }); // "object"
// オブジェクト instanceof コンストラクタ -> boolean
console.log("Hello" instancof String); // false
console.log(new Date() instanceof Date); // true
console.log(1, 2, 3 instanceof Array); // true